{% extends "pm/base.html" %}

{% block pm_breadcrumb %}
<li class="breadcrumb-item active" aria-current="page">证书列表</li>
{% endblock %}

{% block content %}
    <div class="container">
        <div class="panel panel-primary">
            <div class="panel-heading">我的报告</div>
            <div class="panel-body">
                <form method="get">
                    <div class="table-responsive">
                        <table class="table table-condensed"
                               data-toggle="table"
                               id="table"
                               data-toolbar="#toolbar"
                               data-search="true"
                        >
                            <thead>
                            <tr>
                                <th>选择</th>
                                <th>ID</th>
                                <th>部门</th>
                                <th>客户名称</th>
                                <th>仪器名称</th>
                                <th>仪器序列号</th>
                                <th>Created At</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for report in reports %}
                                <tr>
                                    <td><input type="checkbox" name="selected_reports" value="{{ report.id }}"></td>
                                    <td>{{ report.id }}</td>
                                    <td>{{ report.department }}</td>
                                    <td>{{ report.customer_name }}</td>
                                    <td>{{ report.instrument_name }}</td>
                                    <td>{{ report.instrument_serial }}</td>
                                    <td>{{ report.report_date }}</td>
                                    <td><a class='btn btn-success btn-xs'
                                           href="{% url 'download_report' report.id %}">下载</a></td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                {% if page_obj.has_previous %}
                                    <li class="page-item">
                                        <a class="page-link" href="?page={{ page_obj.previous_page_number }}"
                                           aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                {% else %}
                                    <li class="page-item disabled">
                                        <a class="page-link" href="#" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                {% endif %}

                                {% for num in page_obj.paginator.page_range %}
                                    {% if page_obj.number == num %}
                                        <li class="page-item active">
                                            <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                                        </li>
                                    {% else %}
                                        <li class="page-item">
                                            <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                                        </li>
                                    {% endif %}
                                {% endfor %}

                                {% if page_obj.has_next %}
                                    <li class="page-item">
                                        <a class="page-link" href="?page={{ page_obj.next_page_number }}"
                                           aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                {% else %}
                                    <li class="page-item disabled">
                                        <a class="page-link" href="#" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                {% endif %}
                            </ul>
                        </nav>
                    </div>

                </form>
            </div>
        </div>
    </div>
{% endblock %}